home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DLPIRoutines.h
-
- Contains: This file contains the defines necessary for the STREAMS environment.
-
- Written by:
-
- Copyright: © 1994, 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <FW2> 6/20/96 ES Made this look more like a .i generated interface.
- <1> 3/27/96 ES first checked in
-
- To Do:
- */
-
-
- #ifndef __DLPIROUTINES__
- #define __DLPIROUTINES__
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- //-----------------------------------------------------------------------------------------
- // bit definitions for various flags used in the per stream data structure (streamFlags)
- //-----------------------------------------------------------------------------------------
- enum DLPIStreamFlags
- {
- kAutoXID = 0x00000001,
- kAutoTest = 0x00000002,
- kSnapStream = 0x00000004,
- kAcceptMulticasts = 0x00000008,
- kAcceptAll8022Packets = 0x00000010,
- kWriteRawPackets = 0x00000020,
- kReadRawPackets = 0x00000040
- };
-
- //-----------------------------------------------------------------------------------------
- // Used to register Group SAP addresses
- //-----------------------------------------------------------------------------------------
- #define kGroupSAPMapSize 128/32 // number of 32 values we need for 128 bits
- #define kGSshift 6
- #define kGSmask 0x1F
-
- //-----------------------------------------------------------------------------------------
- // Internal Return codes for DLPI
- //-----------------------------------------------------------------------------------------
-
- enum DLPIInternalCodes
- {
- kdlpiDONE = 1,
- kdlpiRETRY = 2
- };
-
- //-----------------------------------------------------------------------------------------
- // Timer Message Types
- //-----------------------------------------------------------------------------------------
-
- enum TimerMessageTypes
- {
- kEnableQueueTimerMsg = 1
- };
-
- //-----------------------------------------------------------------------------------------
- // Write Scheduler Types
- //-----------------------------------------------------------------------------------------
-
- enum DLPISchedulerType
- {
- kdlpiBufcallType = 1
- };
-
- //-----------------------------------------------------------------------------------------
- // Packet Types
- //-----------------------------------------------------------------------------------------
- enum PacketTypes
- {
- kPktDIX = 0,
- kPkt8022SAP = 1,
- kPkt8022GroupSAP = 2,
- kPkt8022SNAP = 3,
- kPktIPX = 4,
- kPktUnknown = 5
- };
-
- //-----------------------------------------------------------------------------------------
- // Ethernet length constants
- //-----------------------------------------------------------------------------------------
- #define kEnetPhysicalAddressLength k48BitAddrLength // 6 bytes for ethernet
- #define kEnetAndSAPAddressLength kEnetPhysicalAddressLength + k8022DLSAPLength
- #define kMaxBoundAddrLength 6 + 2 + 5 // addr + sap + snap
-
- //-----------------------------------------------------------------------------------------
- // New structures
- //-----------------------------------------------------------------------------------------
- struct T8022AddressStruct
- {
- UInt8 fHWAddr[k48BitAddrLength];
- UInt16 fSAP;
- UInt8 fSNAP[k8022SNAPLength];
- };
- typedef struct T8022AddressStruct T8022AddressStruct;
-
- //-----------------------------------------------------------------------------------------
- // One structure per stream for our dlpi
- //-----------------------------------------------------------------------------------------
-
- struct DLPIStream
- {
- struct DLPIStream *nextStream; // queue pointer for active streams
- struct DLPIStream *rxPacketLink; // streams that want a received packet
- queue_t *readQueue;
- UInt32 dlpiState;
- UInt32 timeoutID; // id for bufcalls and timeouts
- UInt16 idType; // type of id (bufcall or timeout)
- UInt16 minorDevice;
- UInt16 dlsap;
- UInt32 group_sap[kGroupSAPMapSize];
- UInt32 streamFlags; // 32 1 bit flags for the stream
- QHdr multicastQueue;
- UInt8 snap[k8022SNAPLength];
- mblk_t *bufferTimerMsg;
- };
-
- typedef struct DLPIStream DLPIStream;
-
- //-----------------------------------------------------------------------------------------
- // Function Prototypes
- //-----------------------------------------------------------------------------------------
-
- SInt32 GetAddressType(UInt8 *);
- SInt32 BindTheStream(DLPIStream *, mblk_t *);
- SInt32 DoEnableMulticast(DLPIStream *, mblk_t *);
- SInt32 DoErrorAck(DLPIStream *, mblk_t *, UInt32, UInt32, UInt32);
- void FindStreamForReceivedPacket(DLPIStream *, mblk_t *);
- SInt32 DoGeneralInfo(DLPIStream *);
- void DoOKAck(DLPIStream *, mblk_t *, UInt32);
- SInt32 DoPhysicalAddressAck(DLPIStream *,mblk_t *);
- SInt32 SubsBindTheStream(DLPIStream *, mblk_t *);
- SInt32 UnSubsBindTheStream(DLPIStream *, mblk_t *);
- SInt32 SendTestPacket(DLPIStream *, mblk_t *, UInt8);
- Boolean TestGroupSAP(DLPIStream *, UInt8);
- SInt32 UnBindTheStream(DLPIStream *, mblk_t *);
- void DoUnitData(DLPIStream *, mblk_t *);
- SInt32 DoXID(DLPIStream *, mblk_t *, UInt8);
- SInt32 DoDisableMulticast(DLPIStream *, mblk_t *);
- mblk_t *BuildPacketHeader(DLPIStream *, mblk_t *, UInt8 *, UInt32, UInt8, UInt8,Boolean);
- SInt32 DoSetPhysicalAddress(DLPIStream *theStream, mblk_t *mp);
- SInt32 DoStatisticsAck(DLPIStream *theStream, mblk_t *mp);
-
-
- mblk_t *BuildBindAck(DLPIStream *, UInt16);
- void BuildXidTestConfirmIndication(DLPIStream *theStream, mblk_t *mp, UInt16 destAddrLength, UInt16 headerHideLength);
- void ClearGroupSAP(DLPIStream *, UInt8);
- void EnableWriteQueue(long);
- SInt32 FindSnap(DLPIStream *, UInt8 *, SInt32);
- void SetGroupSAP(DLPIStream *, UInt8);
- mblk_t *BuildSubsBindAck(DLPIStream *, UInt8 *, SInt32);
- void DoTestResponse(DLPIStream *, mblk_t *);
- void DoUdError(DLPIStream *, UInt8 *, UInt32, UInt32, UInt32);
- void DoWriteScheduler(DLPIStream *, SInt32);
- void DoXidResponse(DLPIStream *, mblk_t *);
- UInt16 ClassifyPacketType(UInt16 primarySAP, UInt16 secondarySAP);
- mblk_t *ReuseMessageBlock(mblk_t *mp,UInt16 dataSizeNeeded);
- void BuildRxDestSrcHeader(T8022FullPacketHeader *packetHeader,T8022AddressStruct *destAddr,T8022AddressStruct *srcAddr,UInt32 dlsap_length);
- Boolean AreAllStreamsUnbound(void);
- void AddXIDInfoToPacketData(DLPIStream *theStream, mblk_t *headerMB, mblk_t *dataMB);
- void BuildUnitDataIndication(DLPIStream *theStream, mblk_t *mp, UInt16 destAddrLength, UInt16 headerHideLength);
- Boolean CheckAddressMatch(UInt8 *, UInt8 *, SInt32);
- void HandleReceivedPacket(DLPIStream *theStream, mblk_t *mp,UInt16 packetType);
- void ExtractSAPValues(T8022FullPacketHeader *fullpkt, UInt16 *sourceSAP, UInt16 *destSAP);
- mblk_t *BuildTxPacketHeader(DLPIStream *theStream, mblk_t *mp, Boolean forFastPathOnly);
- mblk_t *IsAddressRegistered(QHdr *multicastQueue,UInt8 *reqaddr, Boolean dequeueBlock,UInt16 interruptMask);
- UInt16 ClassifyRxPacket(mblk_t *thePacket);
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __DLPIROUTINES__ */
-